﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QuestionInvestig.Business;
using Newtonsoft.Json;
using QuestionInvestig.Models;

namespace QuestionInvestig.Controllers
{
    public class QuestionController : Controller
    {
        // GET: QuestionIndex
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult QuestionIndex()
        {
            return View();
        }

        /// <summary>
        /// 获取问卷信息的接口
        /// </summary>
        /// <param name="InvestigNo"></param>
        /// <param name="memId"></param>
        /// <returns></returns>
        public string GetInvestigInfo(string InvestigNo, string memId)
        {
            var AnswerRecords = new QuestionForegroundService().GetFakeInvestigInfo(InvestigNo, memId);
            var IsAlreadyAnswer = false;
            return JsonConvert.SerializeObject(new { AnswerRecords, ErrorMsg ="", IsAlreadyAnswer , ResponsesCode =0});
        }

        /// <summary>
        /// 保存问卷的接口
        /// </summary>
        /// <param name="saveJson"></param>
        /// <returns></returns>
        public string EditInvestigInfo(string saveJson)
        {
            new QuestionForegroundService().Edit(saveJson);
            return JsonConvert.SerializeObject(new { IsSuccess = true, Msg = "保存成功！" });
        }

        public ActionResult Page()
        {
            return View();
        }
    }
}